package DesignPatern.A14_迭代器模式.QSB.A03_抽象模式;

import java.util.Vector;

/**
 * @Author: Du
 * @Date: 2021/8/2 8:43
 * 具体迭代器
 */
public class ConcreteIterator implements Iterator
{
    private Vector vector = new Vector();
    
    public int cursor = 0;
    
    public ConcreteIterator(Vector vector)
    {
        this.vector = vector;
    }
    
    @Override
    public Object next()
    {
        Object result = null;
        
        if (this.hasNext())
        {
            result = this.vector.get(this.cursor++);
        } else
        {
            result = null;
        }
        return result;
    }
    
    @Override
    public boolean hasNext()
    {
        return !(this.cursor == this.vector.size());
    }
    
    @Override
    public boolean remove()
    {
        this.vector.remove(this.cursor);
        return true;
    }
}
